//
//  KoiSettingItemView.swift
//  KoiAccounting
//
//  Created by 纪洪文 on 13.04.25.
//

import SwiftUI

struct KoiSettingItemView: View {
    
    var itemImage: Image
    var itemTitle: String
    var itemDesc: String
    
    init(itemImageRes: String, itemTitle: String, itemDesc: String = "") {
        self.itemImage = Image(itemImageRes)
        self.itemTitle = itemTitle
        self.itemDesc = itemDesc
    }
    
    init(systemName: String, itemTitle: String, itemDesc: String = "") {
        self.itemImage = Image(systemName: systemName)
        self.itemTitle = itemTitle
        self.itemDesc = itemDesc
    }
    
    var body: some View {
        HStack {
            itemImage
                .resizable()
                .frame(width: 20, height: 20)
                .foregroundColor(Color.koiColorTitle)
            Text(itemTitle)
                .font(.system(size: 14))
                .fontWeight(.medium)
                .foregroundColor(Color.koiColorTitle)
            Spacer()
            Text(itemDesc)
                .font(.system(size: 13))
                .foregroundColor(Color.koiColorTitleSecond)
            Image("koi_ic_arrow_right")
                .resizable()
                .frame(width: 16, height: 16)
        }.padding(EdgeInsets(top: 18, leading: 14, bottom: 18, trailing: 14))
    }
}

@available(iOS 18.0, *)
#Preview {
    @Previewable @State var imageRes = "koi_ic_item_about"
    @Previewable @State var itemName = "设置中心"
    @Previewable @State var itemDesc = "🐠锦鲤记账，天天好运🍀"
    KoiSettingItemView(itemImageRes: imageRes, itemTitle: itemName, itemDesc: itemDesc)
}
